home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / usr_-_Usr_Files / BIN / GLIBCBUG < prev    next >
Text File  |  1999-09-17  |  6KB  |  259 lines

  1. #! /bin/sh
  2. #
  3. # glibcbug - create a bug report and mail it to the bug address.
  4. #
  5. # configuration section:
  6. #       these variables are filled in by configure
  7. #
  8. VERSION="2.0.7"
  9. BUGGLIBC="bugs@gnu.org"
  10. ADDONS="linuxthreads localedata"
  11. HOST="i686-pc-linux-gnu"
  12. CC='gcc -B$(common-objpfx)'
  13. CFLAGS="-g -O2"
  14. BUILD_SHARED="yes"
  15. BUILD_PROFILE="yes"
  16. BUILD_OMITFP="no"
  17. STDIO="libio"
  18.  
  19. PATH=/bin:/usr/bin:/usr/local/bin:$PATH
  20. export PATH
  21.  
  22. TEMP=/tmp/glibcbug.$$
  23.  
  24. BUGADDR=${1-$BUGGLIBC}
  25. ENVIRONMENT=`uname -a`
  26.  
  27. : ${EDITOR=emacs}
  28.  
  29. : ${USER=${LOGNAME-`whoami`}}
  30.  
  31. trap 'rm -f $TEMP $TEMP.x; exit 1' 1 2 3 13 15
  32. trap 'rm -f $TEMP $TEMP.x' 0
  33.  
  34.  
  35. # How to read the passwd database.
  36. PASSWD="cat /etc/passwd"
  37.  
  38. if [ -f /usr/lib/sendmail ] ; then
  39.         MAIL_AGENT="/usr/lib/sendmail -oi -t"
  40. elif [ -f /usr/sbin/sendmail ] ; then
  41.         MAIL_AGENT="/usr/sbin/sendmail -oi -t"
  42. else
  43.         MAIL_AGENT=rmail
  44. fi
  45.  
  46. # Figure out how to echo a string without a trailing newline
  47. N=`echo 'hi there\c'`
  48. case "$N" in
  49. *c)    ECHON1='echo -n' ECHON2= ;;
  50. *)    ECHON1=echo ECHON2='\c' ;;
  51. esac
  52.  
  53. # Find out the name of the originator of this PR.
  54. if [ -n "$NAME" ]; then
  55.   ORIGINATOR="$NAME"
  56. elif [ -f $HOME/.fullname ]; then
  57.   ORIGINATOR="`sed -e '1q' $HOME/.fullname`"
  58. else
  59.   # Must use temp file due to incompatibilities in quoting behavior
  60.   # and to protect shell metacharacters in the expansion of $LOGNAME
  61.   $PASSWD | grep "^$LOGNAME:" | awk -F: '{print $5}' | sed -e 's/,.*//' > $TEMP
  62.   ORIGINATOR="`cat $TEMP`"
  63.   rm -f $TEMP
  64. fi
  65.  
  66. if [ -n "$ORGANIZATION" ]; then
  67.   if [ -f "$ORGANIZATION" ]; then
  68.     ORGANIZATION="`cat $ORGANIZATION`"
  69.   fi
  70. else
  71.   if [ -f $HOME/.organization ]; then
  72.     ORGANIZATION="`cat $HOME/.organization`"
  73.   elif [ -f $HOME/.signature ]; then
  74.     ORGANIZATION=`sed -e "s/^/  /" $HOME/.signature; echo ">"`
  75.   fi
  76. fi
  77.  
  78. # If they don't have a preferred editor set, then use
  79. if [ -z "$VISUAL" ]; then
  80.   if [ -z "$EDITOR" ]; then
  81.     EDIT=vi
  82.   else
  83.     EDIT="$EDITOR"
  84.   fi
  85. else
  86.   EDIT="$VISUAL"
  87. fi
  88.  
  89. # Find out some information.
  90. SYSTEM=`( [ -f /bin/uname ] && /bin/uname -a ) || \
  91.         ( [ -f /usr/bin/uname ] && /usr/bin/uname -a ) || echo ""`
  92. ARCH=`[ -f /bin/arch ] && /bin/arch`
  93. MACHINE=`[ -f /bin/machine ] && /bin/machine`
  94.  
  95. ORGANIZATION_C='<organization of PR author (multiple lines)>'
  96. SYNOPSIS_C='<synopsis of the problem (one line)>'
  97. SEVERITY_C='<[ non-critical | serious | critical ] (one line)>'
  98. PRIORITY_C='<[ low | medium | high ] (one line)>'
  99. CLASS_C='<[ sw-bug | doc-bug | change-request | support ] (one line)>'
  100. RELEASE_C='<release number or tag (one line)>'
  101. ENVIRONMENT_C='<machine, os, target, libraries (multiple lines)>'
  102. DESCRIPTION_C='<precise description of the problem (multiple lines)>'
  103. HOW_TO_REPEAT_C='<code/input/activities to reproduce the problem (multiple lines)>'
  104. FIX_C='<how to correct or work around the problem, if known (multiple lines)>'
  105.  
  106.  
  107. cat > $TEMP <<EOF
  108. SEND-PR: -*- send-pr -*-
  109. SEND-PR: Lines starting with \`SEND-PR' will be removed automatically, as
  110. SEND-PR: will all comments (text enclosed in \`<' and \`>').
  111. SEND-PR:
  112. From: ${USER}
  113. To: ${BUGADDR}
  114. Subject: [50 character or so descriptive subject here (for reference)]
  115.  
  116. >Submitter-Id:    net
  117. >Originator:    ${ORIGINATOR}
  118. >Organization:
  119. ${ORGANIZATION- $ORGANIZATION_C}
  120. >Confidential:    no
  121. >Synopsis:    $SYNOPSIS_C
  122. >Severity:    $SEVERITY_C
  123. >Priority:    $PRIORITY_C
  124. >Category:    libc
  125. >Class:        $CLASS_C
  126. >Release:    libc-${VERSION}
  127. >Environment:
  128.     $ENVIRONMENT_C
  129. `[ -n "$HOST" ] && echo Host type: $HOST`
  130. `[ -n "$SYSTEM" ] && echo System: $SYSTEM`
  131. `[ -n "$ARCH" ] && echo Architecture: $ARCH`
  132. `[ -n "$MACHINE" ] && echo Machine: $MACHINE`
  133. `[ -n "$ADDONS" ] && echo Addons: $ADDONS`
  134. `[ -n "$CFLAGS" ] && echo Build CFLAGS: $CFLAGS`
  135. `[ -n "$CC" ] && echo Build CC: $CC`
  136. `[ -n "$BUILD_SHARED" ] && echo Build shared: $BUILD_SHARED`
  137. `[ -n "$BUILD_PROFILE" ] && echo Build profile: $BUILD_PROFILE`
  138. `[ -n "$BUILD_OMITFP" ] && echo Build omitfp: $BUILD_OMITFP`
  139. `[ -n "$STDIO" ] && echo Stdio: $STDIO`
  140.  
  141. >Description:
  142.     $DESCRIPTION_C
  143. >How-To-Repeat:
  144.     $HOW_TO_REPEAT_C
  145. >Fix:
  146.     $FIX_C
  147. EOF
  148.  
  149. chmod u+w $TEMP
  150. cp $TEMP $TEMP.x
  151.  
  152. eval $EDIT $TEMP
  153.  
  154. if cmp -s $TEMP $TEMP.x; then
  155.     echo "File not changed, no bug report submitted."
  156.     exit 1
  157. fi
  158.  
  159. #
  160. #       Check the enumeration fields
  161.  
  162. # This is a "sed-subroutine" with one keyword parameter
  163. # (with workaround for Sun sed bug)
  164. #
  165. SED_CMD='
  166. /$PATTERN/{
  167. s|||
  168. s|<.*>||
  169. s|^[     ]*||
  170. s|[     ]*$||
  171. p
  172. q
  173. }'
  174.  
  175.  
  176. while :; do
  177.   CNT=0
  178.  
  179.   #
  180.   # 1) Severity
  181.   #
  182.   PATTERN=">Severity:"
  183.   SEVERITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
  184.   case "$SEVERITY" in
  185.     ""|non-critical|serious|critical) CNT=`expr $CNT + 1` ;;
  186.     *)  echo "$COMMAND: \`$SEVERITY' is not a valid value for \`Severity'."
  187.   esac
  188.   #
  189.   # 2) Priority
  190.   #
  191.   PATTERN=">Priority:"
  192.   PRIORITY=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
  193.   case "$PRIORITY" in
  194.     ""|low|medium|high) CNT=`expr $CNT + 1` ;;
  195.     *)  echo "$COMMAND: \`$PRIORITY' is not a valid value for \`Priority'."
  196.   esac
  197.   #
  198.   # 3) Class
  199.   #
  200.   PATTERN=">Class:"
  201.   CLASS=`eval sed -n -e "\"$SED_CMD\"" $TEMP`
  202.   case "$CLASS" in
  203.     ""|sw-bug|doc-bug|change-request|support) CNT=`expr $CNT + 1` ;;
  204.     *)  echo "$COMMAND: \`$CLASS' is not a valid value for \`Class'."
  205.   esac
  206.  
  207.   [ $CNT -lt 3 ] &&
  208.     echo "Errors were found with the problem report."
  209.  
  210.   while :; do
  211.     $ECHON1 "a)bort, e)dit or s)end? $ECHON2"
  212.     read input
  213.     case "$input" in
  214.       a*)
  215.     echo "$COMMAND: problem report saved in $HOME/dead.glibcbug."
  216.     cat $TEMP >> $HOME/dead.glibcbug
  217.         xs=1; exit
  218.         ;;
  219.       e*)
  220.         eval $EDIT $TEMP
  221.         continue 2
  222.         ;;
  223.       s*)
  224.         break 2
  225.         ;;
  226.     esac
  227.   done
  228. done
  229. #
  230. #       Remove comments and send the problem report
  231. #       (we have to use patterns, where the comment contains regex chars)
  232. #
  233. # /^>Originator:/s;$ORIGINATOR;;
  234. sed  -e "
  235. /^SEND-PR:/d
  236. /^>Organization:/,/^>[A-Za-z-]*:/s;$ORGANIZATION_C;;
  237. /^>Confidential:/s;<.*>;;
  238. /^>Synopsis:/s;$SYNOPSIS_C;;
  239. /^>Severity:/s;<.*>;;
  240. /^>Priority:/s;<.*>;;
  241. /^>Class:/s;<.*>;;
  242. /^>Release:/,/^>[A-Za-z-]*:/s;$RELEASE_C;;
  243. /^>Environment:/,/^>[A-Za-z-]*:/s;$ENVIRONMENT_C;;
  244. /^>Description:/,/^>[A-Za-z-]*:/s;$DESCRIPTION_C;;
  245. /^>How-To-Repeat:/,/^>[A-Za-z-]*:/s;$HOW_TO_REPEAT_C;;
  246. /^>Fix:/,/^>[A-Za-z-]*:/s;$FIX_C;;
  247. " $TEMP > $TEMP.x
  248.  
  249. if $MAIL_AGENT < $TEMP.x; then
  250.   echo "$COMMAND: problem report sent"
  251.   xs=0; exit
  252. else
  253.   echo "$COMMAND: mysterious mail failure, report not sent."
  254.   echo "$COMMAND: problem report saved in $HOME/dead.glibcbug."
  255.   cat $TEMP >> $HOME/dead.glibcbug
  256. fi
  257.  
  258. exit 0
  259.